#include <iostream>
using namespace std;

int a[10] = {10,15,12,18,20,32,25,14,16,23};
int n=10;


void show(int p, int q)
{ for(int i=p; i<=q; i++)
    cout << a[i] << " ";
  cout << endl;
}


void selsort(int p, int q)
{ 
  for(int k=q; k>p; k--)
  { int m=p;
    for(int i=p+1; i<=k; i++)
      if(a[i]>a[m]) m=i;
    swap(a[m],a[k]); 
    show(p,q);
  }
  
}


int main()
{
  show(0,n-1);   
  selsort(0,n-1);
  show(0,n-1);
  
  return 0;
}

